#! /bin/sh /usr/share/dpatch/dpatch-run
## 03_full_blas_lapack.dpatch.dpatch by  <david@evans>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Build full drop-in replacements for BLAS and LAPACK.

@DPATCH@

diff --git a/Make.top b/Make.top
index 4e0e89a..60ee35e 100644
--- a/Make.top
+++ b/Make.top
@@ -115,6 +115,7 @@ startup : lib include/
 	$(MAKE) -f Make.top leafstart leaf=src/blas/reference/level1
 	$(MAKE) -f Make.top leafstart leaf=src/auxil
 	$(MAKE) -f Make.top leafstart leaf=src/testing
+	$(MAKE) -f Make.top leafstart leaf=lib/atlas
 	$(MAKE) -f Make.top leafstart leaf=lib
 	$(MAKE) -f Make.top leafstart leaf=bin
 	cd src/blas/gemm ; mkdir KERNEL
@@ -271,6 +272,7 @@ killgrd :
 
 lib :
 	mkdir lib
+	mkdir lib/atlas
 
 include/:
 	mkdir include
diff --git a/makes/Make.lib b/makes/Make.lib
index bd645dc..cc85f8a 100644
--- a/makes/Make.lib
+++ b/makes/Make.lib
@@ -64,6 +64,24 @@ libptcblas.so : libptcblas.a
 	ld $(LDFLAGS) -shared -soname $@ -o $@ --whole-archive libptcblas.a
 libcblas.so : libcblas.a
 	ld $(LDFLAGS) -shared -soname $@ -o $@ --whole-archive libcblas.a
+
+# Build full netlib blas/lapack libraries:
+atlas/libblas.a: libatlas.a libptf77blas.a libptcblas.a
+	mkdir tmp
+	(cd tmp && ar x ../libatlas.a);
+	(cd tmp && ar x ../libptf77blas.a);
+	(cd tmp && ar x ../libptcblas.a);
+	ar r $@ tmp/*.o
+	rm -rf tmp
+
+atlas/liblapack.a: liblapack_atlas.a libatlas.a
+	mkdir tmp
+	(cd tmp && ar x /usr/lib/liblapack_pic.a);
+	(cd tmp && ar x ../liblapack_atlas.a);
+	(cd tmp && ar x ../libptcblas.a);
+	ar r $@ tmp/*.o
+	rm -rf tmp
+
 #
 # Builds one shared lib from all ATLAS files
 #
